package game.ui.controls
{
	import com.greensock.*;
	import engine.core.*;
	import flash.display.*;
	import flash.filters.*;
	import flash.geom.*;
	import flash.text.*;
	import game.actor.*;
	import game.ui.core.*;
	
	public class RxTooltip extends RxUIElement
	{
		protected var m_arrow:DisplayObject;
		protected var m_titleField:RxTextLabel;
		protected var m_messageField:RxTextLabel;
		protected var m_arrowPosition:String;
		protected var m_arrowWidth:int = 0;
		protected var m_arrowHeight:int = 0;
		protected var m_borderSize:uint = 0;
		protected var m_borderColor:uint = 0;
		protected var m_backgroundColor:uint = 0;
		protected var m_arrowColor:uint = 0;
		protected var m_backgroundAlpha:Number = 0.8;
		protected var m_closeButton:RxButtonBase;
		protected var m_mode:int = -1;
		protected var m_actor:RxActor;
		protected var m_autoCloseTime:Number;
		protected var m_drawBackground:Boolean = true;
		protected var m_element:RxUIElement;
		protected var m_placement:String;
		protected var m_tooltipOffset:Point;
		protected var m_container:RxUIElement;
		protected var m_closeCallback:Function;
		protected var m_closeCallbackParams:Array;
		private static const MODE_MOUSE:uint = 0;
		private static const MODE_ACTOR:uint = 1;
		
		public function RxTooltip(param1:String = null, param2:Boolean = false, param3:Boolean = true)
		{
			this.CreateChildren();
			this.SetArrowPosition(param1);
			if (this.m_titleField)
			{
				this.m_titleField.SetMultiline(param2);
			}
			if (param3)
			{
				this.ToggleDropShadow();
			}
			mouseEnabled = false;
			mouseChildren = false;
			InvalidateSize();
		}
		
		public function ToggleDropShadow() : void
		{
			var _loc_1:* = new GlowFilter(0, 0.5, 20, 20);
			AddFilter(_loc_1);
		}
		
		protected function CreateChildren() : void
		{
			this.m_container = new RxUIElement();
			addChild(this.m_container);
			this.m_titleField = RxTextLabel.CreateWithStyle(RxFontStyleConstants.BODY_MEDIUM_BOLD, 16777215, TextFormatAlign.CENTER);
			this.m_container.addChild(this.m_titleField);
		}
		
		public function SetArrowPosition(param1:String) : void
		{
			this.m_arrowPosition = param1;
			if (this.m_arrowPosition != null)
			{
				if (this.m_arrowWidth == 0)
				{
					this.m_arrowWidth = 11;
				}
				if (this.m_arrowHeight == 0)
				{
					this.m_arrowHeight = 9;
				}
				this.CreateArrowDisplay();
			}
			else
			{
				this.m_arrowWidth = 0;
				this.m_arrowHeight = 0;
			}
			InvalidateSize();
		}
		
		protected function CreateArrowDisplay() : void
		{
			if (!this.m_arrow)
			{
				this.m_arrow = new Sprite();
				addChild(this.m_arrow);
			}
			this.DrawArrowDisplay();
		}
		
		protected function DrawArrowDisplay() : void
		{
			var _loc_1:* = this.m_arrow as Sprite;
			_loc_1.graphics.clear();
			_loc_1.graphics.beginFill(this.m_arrowColor, this.m_backgroundAlpha);
			if (this.m_arrowPosition == RxUIPositionConstants.BOTTOM)
			{
				_loc_1.graphics.moveTo(0, 0);
				_loc_1.graphics.lineTo(this.m_arrowWidth, 0);
				_loc_1.graphics.lineTo(this.m_arrowWidth * 0.5, this.m_arrowHeight);
				_loc_1.graphics.lineTo(0, 0);
			}
			else if (this.m_arrowPosition == RxUIPositionConstants.TOP)
			{
				_loc_1.graphics.moveTo(0, this.m_arrowHeight);
				_loc_1.graphics.lineTo(this.m_arrowWidth * 0.5, 0);
				_loc_1.graphics.lineTo(this.m_arrowWidth, this.m_arrowHeight);
				_loc_1.graphics.lineTo(0, this.m_arrowHeight);
			}
			else if (this.m_arrowPosition == RxUIPositionConstants.LEFT)
			{
				_loc_1.graphics.moveTo(this.m_arrowWidth, 0);
				_loc_1.graphics.lineTo(this.m_arrowWidth, this.m_arrowHeight);
				_loc_1.graphics.lineTo(0, this.m_arrowHeight * 0.5);
				_loc_1.graphics.lineTo(this.m_arrowWidth, 0);
			}
			else if (this.m_arrowPosition == RxUIPositionConstants.RIGHT)
			{
				_loc_1.graphics.moveTo(0, 0);
				_loc_1.graphics.lineTo(this.m_arrowWidth, this.m_arrowHeight * 0.5);
				_loc_1.graphics.lineTo(0, this.m_arrowHeight);
				_loc_1.graphics.lineTo(0, 0);
			}
			_loc_1.graphics.endFill();
		}
		
		public function SetData(param1:Object, param2:Boolean = false) : void
		{
			if (param1 is String)
			{
				if (param2)
				{
					this.m_titleField.htmlText = String(param1);
				}
				else
				{
					this.m_titleField.text = String(param1);
				}
			}
			else if (param1.hasOwnProperty("htmlText"))
			{
				this.m_titleField.htmlText = param1.htmlText;
			}
			InvalidateSize();
			this.UpdateDisplayState();
		}
	}
}